/*
 * @Author: qianl
 * @Date: 2024-01-23 16:21:31
 * @LastEditors: qianl
 * @LastEditTime: 2024-02-05 13:53:40
 * @FilePath: \external-website-jxg\src\store\index.js
 * 
 */
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userInfo: {},
    search:{},
    isLogin: false,
    userType:[],
    activeMenuPath:'/shipPlan/addBulk',
  },
  getters: {
    userInfo: state => state.userInfo,
    userType: state => state.userType,
    search:state => state.search,
    isLogin: state => state.isLogin,
    position:state => state.position,
  },
  mutations: {
    SET_POSITION(state, payload) {
      state.position = payload
    },
    SET_USERINFO(state, payload) {
      state.userInfo = payload
      state.userType = payload.customerType !== null ?payload.customerType.split(','):[]
    },
    SET_SEARCH(state, payload) {
      state.search = payload
    },
    SET_ISLOGIN(state, payload) {
      if (payload == false) {
        state.userInfo = {}
      }
      state.isLogin = payload
    },
    setActiveMenuPath(state, payload) {
      state.activeMenuPath = payload
    },
  },
  actions: {
    setPosition({commit}, payload) {
      commit('SET_POSITION', payload)
    },
    setUserInfo({commit}, payload) {
      commit('SET_USERINFO', payload)
    },
    setSearch({commit}, payload) {
      commit('SET_SEARCH', payload)
    },
    setIsLogin({commit}, payload) {
      commit('SET_ISLOGIN', payload)
    },
  },
  modules: {
  }
})
